﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Composite.Regions;
using System.Windows;
using RentAWorker.Management.Infrastructure.CommunicationServices;
using RentsList;
using RentAWorker.Management.Infrastructure;

namespace RentManagement
{
    public class ModuleController : IRentManagementCommService
    {
        private IRegionManager RegionManager { get; set; }
        private IUnityContainer Container { get; set; }

        public ModuleController(IUnityContainer container, IRegionManager regionManager)
        {
            this.Container = container;
            this.RegionManager = regionManager;
        }

        public void Run()
        {
        }

        public void ShowRentsForCustomer(int customerID)
        {
            IRentsListPresentationModel pm = this.Container.Resolve<IRentsListPresentationModel>();

            this.RegionManager.Regions["DetailsRegion"].Clear();
            this.RegionManager.Regions["DetailsRegion"].Add(pm.View);

            pm.Initialize(customerID);

            this.RegionManager.Regions["DetailsRegion"].Activate(pm.View);
        }
    }
}
